home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / tar.gnu / sprite / sprite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-29  |  2.7 KB  |  118 lines

  1. /*
  2.  * sprite.c --
  3.  *    Sprite dependent routines to make named pipes, pseudo devices, etc.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <errno.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10.  
  11. #include "sprite.h"
  12. #include "status.h"
  13. #include "fs.h"
  14. #include "tar.h"
  15.  
  16. /*
  17.  * SpriteMakeNamedPipe --
  18.  *    Create a named pipe under Sprite.  This uses the name from the
  19.  *    tar record header, and the read-write-execute bits from the
  20.  *    mode of the file.  This assumes that the tar tape was made
  21.  *    under Sprite, or that the UNIX read-write-execute bits are
  22.  *    the same as Sprite's, which is indeed the case.
  23.  */
  24. int
  25. SpriteMakeNamedPipe(name, hstat)
  26.     char *name;
  27.     struct stat *hstat;
  28. {
  29.     ReturnStatus status;
  30.     int streamID;
  31.     int flags;
  32.  
  33.     if (f_keep) {
  34.     flags = FS_CREATE|FS_NAMED_PIPE_OPEN|FS_EXCLUSIVE;
  35.     } else {
  36.     flags = FS_CREATE|FS_NAMED_PIPE_OPEN;
  37.     }
  38.  
  39.     status = Fs_Open(name, flags, hstat->st_mode & 0777, &streamID);
  40.     if (status == SUCCESS) {
  41.     (void)Fs_Close(streamID);
  42.     return(0);
  43.     } else {
  44.     /*
  45.      * Let our caller deal with errors.  It may need to make
  46.      * parent directories, etc.
  47.      */
  48.     errno = Compat_MapCode(status);
  49.     return(-1);
  50.      }
  51. }
  52.  
  53. /*
  54.  * SpriteMakePseudoDev --
  55.  *    Create a pseudo device under Sprite.  This uses the name from the
  56.  *    tar record header, and the read-write-execute bits from the
  57.  *    mode of the file.  This assumes that the tar tape was made
  58.  *    under Sprite, or that the UNIX read-write-execute bits are
  59.  *    the same as Sprite's, which is indeed the case.
  60.  */
  61. int
  62. SpriteMakePseudoDev(name, hstat)
  63.     char *name;
  64.     struct stat *hstat;
  65. {
  66.     ReturnStatus status;
  67.     int streamID;
  68.     int flags;
  69.  
  70.     if (f_keep) {
  71.     flags = FS_CREATE|FS_PDEV_MASTER|FS_EXCLUSIVE;
  72.     } else {
  73.     flags = FS_CREATE|FS_PDEV_MASTER;
  74.     }
  75.  
  76.     status = Fs_Open(name, flags, hstat->st_mode & 0777, &streamID);
  77.     if (status == SUCCESS) {
  78.     (void)Fs_Close(streamID);
  79.     return(0);
  80.     } else {
  81.     /*
  82.      * Let our caller deal with errors.  It may need to make
  83.      * parent directories, etc.
  84.      */
  85.     errno = Compat_MapCode(status);
  86.     return(-1);
  87.      }
  88. }
  89.  
  90. /*
  91.  * SpriteMakeRemoteLink --
  92.  *    Create a remote link under Sprite.  This uses the name from the
  93.  *    tar record header, and the read-write-execute bits from the
  94.  *    mode of the file.  This assumes that the tar tape was made
  95.  *    under Sprite, or that the UNIX read-write-execute bits are
  96.  *    the same as Sprite's, which is indeed the case.
  97.  */
  98. int
  99. SpriteMakeRemoteLink(linkname, name)
  100.     char *linkname;    /* Name referred to by link */
  101.     char *name;        /* Name of file created */
  102. {
  103.     ReturnStatus status;
  104.  
  105.     status = Fs_SymLink(linkname, name, TRUE);
  106.     if (status == SUCCESS) {
  107.     return(0);
  108.     } else {
  109.     /*
  110.      * Let our caller deal with errors.  It may need to make
  111.      * parent directories, etc.
  112.      */
  113.     errno = Compat_MapCode(status);
  114.     return(-1);
  115.      }
  116. }
  117.  
  118.